<?php 
 include_once dirname(__FILE__)."/config.php";
 class diplome_principal{
		 protected $_result;
		 protected $_cnn;
		 protected $_CODE_DIPLOME;
		 protected $_LIBELLE_DIPLOME;
		 public function get_name_table(){ return "diplome";}
		 public function get_name_CODE_DIPLOME(){ return "CODE_DIPLOME";}
		 public function get_name_LIBELLE_DIPLOME(){ return "LIBELLE_DIPLOME";}
		 public function set_CODE_DIPLOME($parametre){  $this->_CODE_DIPLOME=$parametre;}	
		 public function set_LIBELLE_DIPLOME($parametre){  $this->_LIBELLE_DIPLOME=$parametre;}	
		 public function get_result(){ return $this->_result;}
		 public function get_CODE_DIPLOME(){ return $this->_CODE_DIPLOME;}
		 public function get_LIBELLE_DIPLOME(){ return $this->_LIBELLE_DIPLOME;}
public function __construct(){

		 	$this->_cnn=new databaseconnect();

		 }

 public function INSERT()
{

$sql=" INSERT INTO 
 diplome(
			CODE_DIPLOME,
			LIBELLE_DIPLOME)
 VALUES(
			'".$this->_CODE_DIPLOME."',
			'".$this->_LIBELLE_DIPLOME."')";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function UPDATE()
{

 $sql="";
if(!empty($this->_CODE_DIPLOME)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
CODE_DIPLOME='".$this->_CODE_DIPLOME."'";
}
if(!empty($this->_LIBELLE_DIPLOME)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
LIBELLE_DIPLOME='".$this->_LIBELLE_DIPLOME."'";
}
$sql="UPDATE 
diplome SET 
 ".$sql."
								WHERE CODE_DIPLOME ='".$this->_CODE_DIPLOME."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function DELETE(){

 $sql="DELETE FROM 
diplome 
 
									WHERE CODE_DIPLOME ='".$this->_CODE_DIPLOME."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function TRANCATE(){

 $sql="DELETE FROM 
diplome ";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function SELECT($constraint="",$pagination="")
{

$sql=" SELECT 
 		CODE_DIPLOME,
		LIBELLE_DIPLOME
 FROM 
 diplome";
if($constraint){$sql.=" WHERE 1=1 ".$constraint;}if($pagination){$sql.=$pagination;}
$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}
public function fetch_object(){
$row=mysql_fetch_object($this->_result);
 if($this->_result){
 if($row){
		$this->_CODE_DIPLOME=$row->CODE_DIPLOME;
		$this->_LIBELLE_DIPLOME=$row->LIBELLE_DIPLOME;
		return $row;
		}else{
					return false;
				}

			}else{
				//echo 'Erreur d\'execution de requette de selection';	
			}
			

		}

}
?>